home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / MinerX.dxr / 00033_Drone Scripts.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  2.5 KB  |  94 lines

  1. on setDroneConstants
  2.   global droneData, droneSO, maxDrones
  3.   droneSO = 25
  4.   maxDrones = 250
  5. end
  6.  
  7. on initializeDrones
  8.   global droneData, droneSO, maxDrones, wTest
  9.   droneData = []
  10.   repeat with wDrone = 1 to maxDrones
  11.     wSprite = wDrone + droneSO - 1
  12.     add(droneData, [0, point(random(5800), random(4400))])
  13.     puppetSprite(wSprite, 1)
  14.     set the member of sprite wSprite to "Drone1"
  15.     set the loc of sprite wSprite to point(-50, -50)
  16.     set the ink of sprite wSprite to 36
  17.   end repeat
  18.   wTest = 0
  19. end
  20.  
  21. on addDrone
  22.   global droneData, droneSO, maxDrones, wTest
  23.   case random(2) of
  24.     1:
  25.       spawnloc = point([0, 5800][random(2)], random(4400))
  26.     2:
  27.       spawnloc = point(random(5800), [0, 4400][random(2)])
  28.   end case
  29.   validSlot = 0
  30.   repeat with wS = 1 to maxDrones
  31.     if validSlot = 0 then
  32.       if droneData[wS][1] = 0 then
  33.         validSlot = wS
  34.       end if
  35.     end if
  36.   end repeat
  37.   if validSlot <> 0 then
  38.     droneData[validSlot] = [1, spawnloc]
  39.   end if
  40. end
  41.  
  42. on runDrones
  43.   global droneData, droneSO, maxDrones, bgOffset, wTest, playerData, totalDrones, droneSwitch
  44.   totalDrones = 0
  45.   droneSwitch = droneSwitch + 1
  46.   if droneSwitch > 2 then
  47.     droneSwitch = 1
  48.   end if
  49.   repeat with wDrone = 1 to maxDrones
  50.     if droneData[wDrone][1] = 1 then
  51.       totalDrones = totalDrones + 1
  52.       wSprite = wDrone + droneSO - 1
  53.       dLoc = droneData[wDrone][2]
  54.       mloc = playerData[2]
  55.       turnAdjust = random(12) - 6
  56.       moveAim = findAngle(dLoc, mloc) + turnAdjust
  57.       moveDist = findDistance(dLoc, mloc) / 10
  58.       if moveDist > (5 + (wDrone mod 10)) then
  59.         moveDist = 5 + (wDrone mod 10)
  60.       end if
  61.       locY = integer(cos(moveAim * PI / 180) * -moveDist)
  62.       locX = integer(sin(moveAim * PI / 180) * moveDist)
  63.       droneData[wDrone][2] = droneData[wDrone][2] + point(locX, locY)
  64.       set the loc of sprite wSprite to (dLoc / 10) + bgOffset
  65.     end if
  66.   end repeat
  67.   wTest = wTest + 1
  68.   if wTest > maxDrones then
  69.     wTest = wTest - maxDrones
  70.   end if
  71.   terminate = 0
  72.   coreloc = droneData[wTest][2]
  73.   repeat with wScan = 1 to maxDrones
  74.     if wScan <> wTest then
  75.       if droneData[wScan][1] = 1 then
  76.         dLoc = droneData[wScan][2]
  77.         dist = findDistance(coreloc, dLoc)
  78.         if dist <= 15 then
  79.           wSprite = wScan + droneSO - 1
  80.           set the loc of sprite wSprite to point(-10, -10)
  81.           droneData[wScan][1] = 0
  82.         end if
  83.       end if
  84.     end if
  85.   end repeat
  86. end
  87.  
  88. on playSound whichSound, whichSlot
  89.   global lastClear
  90.   sound(whichSlot).stop()
  91.   sound(whichSlot).queue([#member: member(whichSound)])
  92.   sound(whichSlot).play()
  93. end
  94.